//
//  GYLoggerFormater.m
//  GYLogger
//
//  Created by APPLE on 2020/6/22.
//  Copyright © 2020 APPLE. All rights reserved.
//

#import "GYLoggerFormater.h"

@implementation GYLoggerFormater

- (NSString *)formatLogMessage:(DDLogMessage *)logMessage {
    NSString * tip      = [NSString stringWithFormat:@"Level    \t%@\n",[self logLevelTipWithLevel:logMessage -> _level]];
    NSString * fileName = [NSString stringWithFormat:@"FileName \t%@\n",logMessage -> _fileName];
    NSString * function = [NSString stringWithFormat:@"Function \t%@\n",logMessage -> _function];
    NSString * queue    = [NSString stringWithFormat:@"Queue    \t%@\n",logMessage -> _queueLabel];
    NSString * division = @"------------------------------- \n";
    NSString * message =  [NSString stringWithFormat:@"%@\n",logMessage -> _message];
    
    
    return [NSString stringWithFormat:@"\n%@%@%@%@%@%@",tip,fileName,function,queue,division,message];
}

- (NSString *)logLevelTipWithLevel:(DDLogLevel)level {
    NSString * levelTip;
    switch (level) {
        case DDLogLevelVerbose  : levelTip = @"Verbose "; break;
            
        case DDLogLevelWarning  : levelTip = @"Warning "; break;
        
        case DDLogLevelInfo     : levelTip = @"Info    "; break;
            
        case DDLogLevelDebug    : levelTip = @"Debug   "; break;
            
        default                 : levelTip = @"Defalut "; break;
    }
    return levelTip;
}

@end
